<!--
 * @Description: 
 * @Autor: wangwangwang
 * @Date: 2021-01-12 12:08:10
 * @LastEditors: wangwangwang
 * @LastEditTime: 2021-04-19 15:49:50
-->
<template>
  <div id="viewFile" style="height:100%;"></div>
</template>
<script>
import { getToken } from '@/utils/auth';
import * as WPS from '@/utils/jwps.es6'
export default {
  props: ['wpsUrl'],
  data() {
    return {
      simpleMode: true
    }
  },
  watch: {
    wpsUrl (value) {
      this.openWps(value);
    },
  },
  mounted() {
    this.openWps(this.wpsUrl);
  },
  methods: {
    openWps(url) {
      const wps = WPS.config({
        mode: 'simple',
        mount: document.querySelector('#viewFile'),
        wpsUrl: url,
        commonOptions: {
          isShowTopArea: false,
          isShowHeader: false,
          isIframeViewFullscreen: true,
        }
      });
      wps.setToken({ "token": getToken() });
    }
  }
}
</script>
<style>
#wps-iframe {
  display: flex;
  flex-direction: column;
  padding: 0;
  margin: 0;
  height: 100%;
  /* 防止双击缩放 */
  touch-action: manipulation;
}
</style>

